param(
    [string]$Qemu = "qemu-system-x86_64",
    [string]$TinyGo = "tinygo",
    [string]$Nasm = "nasm",
    [string]$Linker = "ld.lld",
    [string]$Objcopy = "llvm-objcopy",
    [string]$Display = "sdl"  # 优先使用 SDL 窗口，避免 curses 键盘问题
)

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

$buildScript = Join-Path $PSScriptRoot "build.ps1"
& $buildScript -TinyGo $TinyGo -Nasm $Nasm -Linker $Linker -Objcopy $Objcopy

$root = Resolve-Path (Join-Path $PSScriptRoot "..")
$osImg = Join-Path $root "build\os.img"

# Attach an Intel e1000 NIC with user-mode networking for testing
& $Qemu "-drive" "format=raw,file=$osImg" "-serial" "stdio" "-display" $Display "-netdev" "user,id=n0" "-device" "e1000,netdev=n0"
